/*
 * ModulusExp.cpp
 *
 *  Created on: Sep 22, 2012
 *      Author: calle
 */

#include <AbsSyn/ModulusExp.h>
#include <Interfaces/IExpVisitor.h>
#include <stdio.h>
#include <AbsSyn/IntExp.h>
#include <boost/bind.hpp>


ModulusExp::ModulusExp(AbsSyn::IExpPtr lhs, AbsSyn::IExpPtr rhs ):
m_lhs(lhs),
m_rhs(rhs)
{


}


ModulusExp::~ModulusExp() {

}

void ModulusExp::accept(IExpVisitor* v) {
	 v->VisitModulusExp(this);
}

IExp* ModulusExp::clone() const {
	return (new ModulusExp(m_lhs,m_rhs));
}

std::string ModulusExp::toString() const {
	std::string ret;
	assert(m_lhs);
	assert(m_rhs);

	if(m_lhs && m_rhs)
	{
		ret = "(" + m_lhs->toString() + " % " + m_rhs->toString() + ")";
	}

	return ret;
}

AbsSyn::IExpPtr ModulusExp::generateModExp(GenExp& genObj) {
	AbsSyn::IExpPtr arg1 = genObj.genExp(GenExp::RANDOM);
	AbsSyn::IExpPtr arg2 = genObj.genExp(GenExp::RANDOM);

	assert(arg1 != NULL);
	assert(arg2 != NULL);

	AbsSyn::IExpPtr ptr(new ModulusExp(arg1,arg2) );
	return ptr;
}



